

from multiprocessing import Process , Queue
from time import sleep


def write(q):
    for tt in [1, 2, 3, 4, 5, 6, 7, 8, 9]:
        q.put(tt)


def read(q):
    while True:
        print(q.get())
        sleep(1)


if __name__ == '__main__':
    print("启动线程")

    q = Queue()

    p1 = Process(target=write, args=(q,))
    p2 = Process(target=read, args=(q,))

    p1.start()
    p2.start()

